Why am I getting UNBOUNDLOCALERROR with a global variable in my Python function